﻿
@{
    Layout = "~/Views/Shared/_Layout1.cshtml";
    ViewBag.Title = "Add";
}

<article class="cl pd-20">
    <form action="@Url.Action("AddPer","Permissions")" method="post" class="form form-horizontal" id="form-edit">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权限名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text"  placeholder="" name="Name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权限描述：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text"  placeholder="" name="Description">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>
@section footScript{
    <script type="text/javascript">
        $(function () {

            $("#form-edit").validate({
                rules: {
                    Name: {
                        required: true,
                        maxlength:50
                    },
                    Description: {
                        required: true,
                        maxlength:100
                    },
                },

                messages: {
                    Name: {
                        required: "权限名称不能为空"
                    },
                    Description: {
                        required: "权限描述不能为空"
                    }
                },

                //提交表单
                submitHandler: function (form) {
                    //使用ajax方式提交表单
                    $(form).ajaxSubmit({
                        success: function (data) {
                            console.log(data)
                            //State=1成功，-1失败
                            if (data.State == 1) {
                                //刷新页面
                                parent.location.reload();
                            } else {
                                layer.msg(data.ErrorMessage, { icon: 2 });
                            }
                        }
                    });
                }
            });
        });
    </script>
}

